package com.person.cloud.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author zhangfc
 * @date 2021/9/10 16:29
 */
@Configuration
public class WebConfiguration implements WebMvcConfigurer {

    /*
    跨域问题解决
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/*")
                .allowedOrigins("*")
                .allowCredentials(true)
                .allowedMethods("GET","POST","DELETE","PUT","PATCH")
                .maxAge(3600);
        WebMvcConfigurer.super.addCorsMappings(registry);
    }
}
